home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gigarom 1
/
Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso
/
FILES
/
BBS
/
MUBBS
/
MUBBS etc.cpt
/
Module Source
/
Files Module
/
Files Module Main.c
< prev
next >
Wrap
Text File
|
1991-11-22
|
25KB
|
871 lines
/*
* Files Module Main.c
*
* This program source code and it's compiled version is
* Copyright (c) 1991 N. Hawthorn.
* This program source code and it's compiled version IS NOT IN THE
* PUBLIC DOMAIN ! Please read the "COPYRIGHT NOTICE / NH" file for details
* regarding use of this program source code and it's compiled version.
*
* This module's name is "files", it's type is "MOD1", use a resource mover
* to assign a new number to it, that's why we name our modules !
*
* This is where it all starts...
*
*/
#define INMAIN
#include <SetUpA4.h>
#include "MUBBS Module.h"
struct PPP {
char filename[256]; /* the whole file and folder name */
char justname[64]; /* just the file name (for the user to see) */
long size; /* the size of a file either received or sent */
int mode; /* the mode send, receive */
int result; /* the result of the transfer */
char reserved[32]; /* some extra bytes for future use */
};
#define RECEIVE 0 /* Receive a file */
#define SEND 1 /* Send a file */
#define ABORT 1 /* Return ERROR */
#define NOTFOUND 2 /* Return ERROR */
#define NOCREATE 3 /* Return ERROR */
#define MAX_DESC_LINES 3
#define MAX_DESC_CHAR 80
#define CHARSPERFILE 308
#define MAXFILETRIES 10
/* my globals for this file */
pascal void main (mode1,G1,P) /* called from the main routines, and what mode to be in */
int mode1;
struct GS *G1; /* we point to the "global" struct in the Main Module here */
Ptr P; /* we ignore this pointer, we do not use it at all */
{
Handle temph;
float version = 0.5; /* what version of MUBBS you are compatable with IE: .5 and above */
RememberA0(); SetUpA4(); /* This sets up the A4 register to access our globals */
asm { _RecoverHandle }; asm {move.l a0,temph}; HLock(temph); /* locks our module, do this ! */
G=G1; /* This MUST be the first thing you do in main only, it sets up the struct globals */
mode[u]=mode1; /* set up our mode so that you can read it anywhere */
switch (mode[u]) { /* any un-handled modes return error from this module */
case 2:
doit();
G->moduleresult=0;
break;
case 98:
versionck(version); /* just return after this call, don't modify anything */
break;
case 0:
strcpy (G->programmer,"N Hawthorn"); /* show the programmer's name up to 20 chars*/
G->moduleresult=0; /* this was also a init call if we need close call put 99 here */
break;
default:
G->moduleresult=1; /* return bad code */
};
HUnlock(temph); /* unlocks this module, do this ! */
RestoreA4(); /* call this when you are all done */
}
doit(){
char temp[31], folder[256], dirfile[256], blank[31], tempstring[256];
int a,b,x,t,chars,type;
FILE *stream;
if (!G->online[u]) goto done; /* do this check so we can log out if hang up */
loguser("In Files Module"); /* this tells where you are for remote sysop, or writes to log file */
/* you print the following so that the sysop can monitor use on the mac screen */
print("C> Line %d %s, at: Files\n",(u+1),G->username[u]);
G->okcancel[u]=TRUE;
G->nocheck[u]=FALSE; /* check for controls */
G->cancel[u]=FALSE;
sendtext(":files:fileintro.txt");
strcpy(folder,":files"); /* start with the files folder */
a=TRUE;
while(a){
strcpy(dirfile,folder);
strcat(dirfile,":directory");
if ((stream = fopen(dirfile, "r")) == NULL) {
print("FILE ERROR - cannot open %s\n",dirfile);
send("]FILE ERROR - Cannot open a directory file]");
return FALSE;
}
else print("directory %s\n",dirfile);
fscanf(stream,"%10[^\n]\n",temp); /* find out what type it is */
type=strtoint(temp);
if(type <=2) { /* it's a folder directory */
b=TRUE;
while (b){
if (type ==2){ /* if it's type 2, generate your own menu */
strcpy(tempstring,folder);
strcat(tempstring,":filemenu");
if (G->language[u] == 1)
strcat(tempstring,".ansi");
else
strcat(tempstring,".txt");
G->okcancel[u]=TRUE;
G->nocheck[u]=FALSE; /* check for controls */
G->cancel[u]=FALSE;
sendtext(tempstring);
}
else {
send("] *** File Menu ***]]>> ");
x=FALSE; /* make a menu */
chars=0;
fseek(stream,0,0); /* start at the beginning of the file again */
fscanf(stream,"%30[^\n]\n",blank); /* take out the directory type, if EOF it will get it later */
while (fscanf(stream,"%30[^\n]\n",temp) != EOF){ /* get all chars */
temp[16]= '\0'; /* limit the display to 15 chars */
if (chars > 60) { /* if another name won't fit on screen */
send("]>> "); /* send a CR */
chars=0; /* show new line */
x=FALSE; /* for new line */
}
if (x) {
send (", ");
chars++; /* account for the , */
chars++;
}
for (t=0; temp[t] != 0; t++) { /* un scramble it */
if (temp[t] != ':') G->out(temp[t]); /* don't print the ":" */
chars++; /* count the characters outputed so far */
}
x=TRUE;
}
if (chars > 50) send("]>> "); /* send a CR */
else send (", Help, Logoff, Quit ");
}
if (!(cmd1(":"))) {
fclose(stream);
goto done;
}
send(G->CR[u]);
if(G->input[u] == 'Q') {
if (!backup(folder)){ /* are we all the way back? */
a=FALSE;
b=FALSE; /* kill everything and quit out */
break;
}
b=FALSE; /* try a new folder */
break;
}
if(G->input[u] == 'L') {
G->online[u]=FALSE;
a=FALSE;
b=FALSE; /* log off, kill everything */
break;
}
if(G->input[u] == 'H') {
G->okcancel[u]=TRUE;
G->nocheck[u]=FALSE; /* check for controls */
G->cancel[u]=FALSE;
sendtext(":files:filehelp1.txt");
continue;
}
fseek(stream,0,0); /* start at the beginning of the file again */
fscanf(stream,"%30[^\n]\n",blank); /* take out the directory type, if EOF it will get it later */
while (fscanf(stream,"%30[^\n]\n",temp) != EOF){ /* go through all the choices */
if (toupper(temp[1]) == G->input[u]){ /* do we have a FIRST character match ? */
strcat(folder,temp); /* make a new "folder" string */
b=FALSE; /* don't do the menu again */
break;
}
}
} /* closes the while (b) */
} /* closes the "if type=" */
fclose(stream); /* close the file, it's not needed anymore */
if(type ==3) { /* it's a folder directory */
fileget(folder); /* show the file list, let them get a file */
if (!backup(folder)){ /* are we all the way back? */
a=FALSE;
break;
}
}
} /* closes the while (a) */
done:
return;
}
fileenter(folder)
char *folder;
{
char fname[65], sizes[12], by[26], extra1[7], deslens[7], des[227],temp[65];
char uploadfile[70], datetime[25];
int bad, index, index2, err, tries;
unsigned long deslen;
FILE *stream, *stream2;
int oldrefnum, newrefnum, i;
struct PPP P;
bad = FALSE;
if (strcmp(G->userbaud[u],"300") == 0) {
send("]Users logged in at 300 baud are not allowed to upload/download here.]");
return;
}
send("]]Your uploads are greatly appreciated by all !]");
poop:
if (G->local[u]) {
send ("]Can't UPLOAD on LOCAL !]");
goto bb; /* cancel pressed */
}
send("]Input filename for upload (24 characters MAX) :");
portsin(fname, 24);
if (! G->online[u]) goto bb; /* portsin returns online for a time out */
send(G->CR[u]);
if (strlen(fname) < 1) { send ("]Upload canceled.]"); goto bb; }
if (strlen(fname) < 4) {send ("]Please use a more descriptive filename.]"); goto poop;}
if (strchr(fname, '*')) bad = TRUE; /* returns TRUE if it's "*" */
if (strchr(fname, ':')) bad = TRUE; /* returns TRUE if it's ":" */
if (strchr(fname, '\\')) bad = TRUE; /* returns TRUE if it's "\" */
if (strchr(fname, '~')) bad = TRUE; /* returns TRUE if it's "~" */
strcpy(temp,fname);
strtoupper(temp);
if(strcmp(temp,"SYSOP") == 0) bad = TRUE; /* returns TRUE if it's a bad name */
if(strcmp(temp,"SYSTEM") == 0) bad = TRUE;
if(strcmp(temp,"FINDER") == 0) bad = TRUE; /* we DON'T want people to upload over this stuff !! */
if(strcmp(temp,"DIRECTORY") == 0) bad = TRUE;
if(strcmp(temp,"FILEINTRO.TXT") == 0) bad = TRUE;
if(strcmp(temp,"FILEHELP1.TXT") == 0) bad = TRUE;
if(strcmp(temp,"FILEHELP2.TXT") == 0) bad = TRUE;
if(strcmp(temp,"FILEMENU.TXT") == 0) bad = TRUE;
if(strcmp(temp,"FILEMENU.ANSI") == 0) bad = TRUE;
if (bad) {
send("]Illegal character in filename or illegal filename!]");
return;
}
strcpy(uploadfile, folder); /* folder can be up to 40 characters */
strcat(uploadfile, ":");
strcat(uploadfile, fname);
print("C> checking for existing file to upload %s\n",uploadfile);
if ((stream = fopen(uploadfile, "r")) != NULL) { /* see if we can read it */
send("]That file name already exists !]Please check the list for this section !]");
fclose(stream);
goto bb;
}
print("C> NEW FILE! allowing upload of %s\n",uploadfile);
if ( ! enterdesc(fname,des)) goto bb; /* get the description lines */
choice:
send("]Upload choices, please select one]");
if (!(cmd1("]Xmodem, Quit :"))) goto bb; /* timeout */
send(G->CR[u]);
switch (G->input[u]) {
case ('X'):
send ("]Ready to upload file \"");
send (fname);
send ("\"]");
print("\nUpload Whole filename =%s ",uploadfile);
goto getit;
break;
case ('Q'):
send ("]Upload canceled.]");
goto bb;
break;
default:
goto choice;
}
getit:
if (!filereceive(uploadfile,fname,&P)) { /* get the file, delete it if transfer bad */
remove(uploadfile);
goto bb;
}
strcpy(uploadfile,folder); /* use "uploadfile"'s string space again */
strcat(uploadfile,":directory");
gettime("%m/%d/%y",datetime); /* gets the date in m/d/y */
strcpy(by,G->username[u]);
if ((P.size=P.size/1000)<1) P.size=1;
longtostr(P.size,sizes); /* do a conversion first */
strcpy(extra1,"");
deslen = strlen(des);
longtostr(deslen,deslens);
tries = 0;
bsylp:
if ((stream = fopen(uploadfile, "a")) == NULL) { /* now write it to the directory */
if (++tries < MAXFILETRIES) {
send("]FILE LIST FILE BUSY, PLEASE STANDBY");
wait(1); /* wait just a bit */
goto bsylp;
}
print("FILE ERROR - cannot open %s\n",uploadfile);
send("]FILE ERROR - Can't open the file list file !]");
send("]YOUR FILE MAY NOT APPEAR IN THE LIST, NOTIFY A SYSOP !!]");
}
else {
print("update to directory %s\n",uploadfile); /* not really the upload file, the directory ! */
if (fprintf(stream,"%-24s~%-10s~%-8s~%-24s~%-5s~%-5s~%-225s~",
fname, /* the file name */
sizes, /* size of the file */
datetime, /* date uploaded */
by, /* by who */
extra1, /* extra data */
deslens, /* length of the description in bytes, the description to 225 bytes */
des ) == EOF) print("bad fprintf conversion\n");
}
fclose(stream);
tries=0;
bsylp1:
if ((stream = fopen(":logs:uploadlog", "a")) == NULL) {
if (++tries < MAXFILETRIES) {
send("]PLEASE STANDBY...");
wait(1); /* wait just a bit */
goto bsylp1;
}
print("FILE ERROR - cannot open uploadlog\n");
send("]FILE ERROR - Can't open/create upload log file!]");
}
else {
if (fprintf(stream, "%s %s UPLOADED \"%s\" %s %sK\n", datetime, by, fname, folder, sizes) < 0) {
send("]FILE ERROR - Upload log file file has problem writing]");
}
}
fclose(stream);
send("]File list has been updated]");
bb:
bad=0;
}
enterdesc(fname,des) /* enter the description */
char *fname,*des;
{
char text[5][MAX_DESC_CHAR + 3],lineshow[90];
int editmode;
strcpy(lineshow," ---------1---------2---------3---------4---------5---------6---------7---------8");
strcpy(text[0],"\0");
strcpy(text[1],"\0");
strcpy(text[2],"\0"); /* clear these guys out */
strcpy(text[3],"\0");
editmode=FALSE;
getline0:
send("]Please describe the file \"%s\" so others can identify it.]]",fname);
send(" YOU CAN ENTER 2 FULL LINES OF DESCRIPTION AND 1 KEYWORD LIST]]");
send("The first line is the \"short\" description that is seen most often.]");
send("To cancel the upload, enter a carriage return on an empty line.]]");
send("%.*s!]01:",(33),lineshow); /* show 30 chars max */
portsin(text[0], 30);
if (! G->online[u]) goto byebye; /* returns online for a time out */
if (strlen(text[0]) == 0) goto cancel;
if (strlen(text[0]) < 10) {
send("]]You can describe it better than that, please try again...]");
goto getline0;
}
strcat(text[0]," "); /* always add a space here */
send(G->CR[u]);
if (editmode) goto edit;
getline1:
send("]The second line is the REST of line 1's description seen on full length lists]");
send("(space already added). To leave blank, enter a carriage return on an empty line.]]");
send("%.*s!]02:",(47),lineshow); /* show 44 chars max */
portsin(text[1], 44);
if (! G->online[u]) goto byebye; /* returns online for a time out */
send(G->CR[u]);
if (editmode) goto edit;
if (strlen(text[1]) == 0) goto getkeys;
getline2:
send("]The third line is the extended description seen on extended length lists.]");
send("To leave blank, enter a carriage return on an empty line.]]");
send("%.*s!]03:",(78),lineshow); /* show 75 chars max */
portsin(text[2], 75);
if (! G->online[u]) goto byebye; /* returns online for a time out */
send(G->CR[u]);
if (editmode) goto edit;
getkeys:
send("]Please enter some KEYWORDS that will help in finding this file during a search.]");
send("Put a space between words. EXAMPLE: processing word graphics business]");
send("To end or if you have none, enter a carriage return on an empty line.]]");
send("%.*s!] K:",(68),lineshow); /* show 65 chars max */
portsin(text[3], 65);
if (! G->online[u]) goto byebye; /* returns online for a time out */
send(G->CR[u]);
if (editmode) goto edit;
tryagain:
if (!(cmd1("]Edit, List, Save, Quit :"))) goto byebye;
send(G->CR[u]);
switch (G->input[u]) { /* get 1 byte */
case ('E'): /* edit message */
goto edit;
break;
case ('L'): /* list message */
send("]]01=%s]",text[0]);
send("02=%s]",text[1]);
send("03=%s]",text[2]);
send("KEYWORDS=%s]]",text[3]);
break;
case ('S'): /* save description */
strcpy(des,text[0]);
if (strlen(text[1]) >0) strcat(des,text[1]);
strcat(des,"\x0A"); /* add a end of line */
if (strlen(text[2]) >0) strcat(des,text[2]);
strcat(des,"\x0A"); /* add a end of line */
if (strlen(text[3]) >0) strcat(des,text[3]);
strcat(des,"\x0A"); /* add a end of line */
return TRUE;
break;
case ('Q'): /* get out w/out saving */
if (!(cmd1("]Are you sure you want to QUIT ? (Y/N) :"))) goto byebye;
if (G->input[u] == 'Y') goto cancel;
goto tryagain;
break;
}
goto tryagain;
edit:
send("]Which line to edit (Quit goes back to the \"Edit\" menu) ?]");
if (!(cmd1("1, 2, 3, K, List, Quit :"))) goto byebye;
send(G->CR[u]);
switch (G->input[u]) { /* get 1 byte */
case ('1'): /* edit message */
editmode = TRUE;
goto getline0;
break;
case ('2'): /* edit message */
editmode = TRUE;
goto getline1;
break;
case ('3'): /* edit message */
editmode = TRUE;
goto getline2;
break;
case ('K'): /* edit message */
editmode = TRUE;
goto getkeys;
break;
case ('L'): /* list message */
send("]]01=%s]",text[0]);
send("02=%s]",text[1]);
send("03=%s]",text[2]);
send("KEYWORDS=%s]]",text[3]);
break;
case ('Q'): /* edit message */
goto tryagain;
break;
}
goto edit;
cancel:
send("]]Upload canceled]]");
return FALSE;
byebye:
G->online[u]=FALSE; /* show we timed out */
return FALSE;
}
backup(folder) /* backs up to the first found ":" */
char *folder;
{
int len;
len = strlen(folder) - 1;
while ((folder[len] != ':') && (len > 0)){
folder[len] = '\0';
len--;
}
folder[len] = '\0'; /* take out the ":" */
if (len==0) return FALSE;
return TRUE;
}
fileget(folder)
char *folder;
{
/* set this to the size of a whole entry in the dir plus the ~ characters*/
char line1[227], dirfile[70];
char fname[27], sizes[13], by[27], extra1[8], deslens[8], des[228], blank[31];
char datetime[26], temp[65];
int count, lines, marked, marked1, page, err, tries, got, empty;
long int seek,startfile,endfile,wherewewere, size;
unsigned long deslen;
char filepick[11][28];
char filemark[11][28];
int downflag[11];
FILE *stream;
struct PPP P;
strcpy(dirfile,folder);
strcat(dirfile,":directory");
print("directory %s\n",dirfile);
if ((stream = fopen(dirfile, "r")) == NULL) {
print("FILE ERROR - cannot open %s\n",dirfile);
send("]FILE ERROR - Cannot open file list file]");
return FALSE;
}
page=1;
marked=0;
empty=FALSE;
fscanf(stream,"%30[^\n]\n",blank); /* take out the directory type, if EOF it will get it later */
if(feof(stream)) {
fclose(stream);
send("]]This file section is empty. You can UPLOAD here by selecting \"U\".]");
empty=TRUE;
goto loop;
}
startfile=ftell(stream);
if(err=fseek(stream,0,2) != 0) print("Fseek to end failed\n"); /* go to end of file */
endfile=ftell(stream);
seek=endfile-CHARSPERFILE; /* back up one record */
fclose(stream);
send("]New files are displayed first.");
next:
if ((stream = fopen(dirfile, "r")) == NULL) { /* only leave it open shortly */
print("FILE ERROR - cannot open %s\n",dirfile);
send("]FILE ERROR - Cannot open file list file]");
return FALSE;
}
lines=0;
if (!G->cancel[u] && !empty) send("]]Page %d FILENAME SIZE (K) DATE UPLOADED BY]",page);
G->linecnt[u]=1; /* start as if it's a new page ! (with one line already here) */
if(err=fseek(stream,seek,0) != 0) print("Fseek failed\n");
while (got=fscanf(stream,"%26[^~]~%12[^~]~%25[^~]~%26[^~]~%7[^~]~%7[^~]~%227[^~]~",
fname,
sizes,
datetime,
by,
extra1,
deslens,
des)) {
if (got != 7) { /* 7 items should have been read here*/
send("]]ERROR found in this file directory, TELL A SYSOP !!]");
break;
}
seek=seek-CHARSPERFILE;
P.size = strtolong(sizes); /* do a conversion */
deslen = strtolong(deslens);
strcpy(filepick[lines],fname); /* save the file name for picking it out */
if (!G->cancel[u]) {
send("%d> %s %s %s %s] ",lines,fname,sizes,datetime,by);
if (G->cancel[u]) goto canceled;
count=0;
strncpy(line1,des,(deslen+1)); /* move the whole description over */
line1[deslen] = 0; /* make sure its terminated, the array starts at 0, remember that*/
while ((line1[count] != '\n') && (line1[count] != '\0') && (count <76) && (!G->cancel[u])) {
G->out(line1[count]); /* only print up to 75 of the characters */
count++;
}
if (!G->cancel[u]) send(G->CR[u]);
}
canceled:
lines++;
if(lines >9) break;
if(seek < startfile) break;
if(err=fseek(stream,seek,0) != 0) print("Fseek failed\n");
}
fclose(stream);
loop:
if (!(cmd1("]>> # to mark, Marked, Next, Prev, Options, Upload, Help, Quit (CR = next) : "))) goto done;
send(G->CR[u]);
if(empty) {
switch (G->input[u]) {
case 'U':
fileenter(folder); /* allow them to upload */
goto alldone;
break;
case 'Q':
goto done;
break;
}
goto loop;
}
if (G->input[u] >= '0' && G->input[u] <= (lines+0x2F)) {
if (marked>9) {
send ("]You have 10 files already marked, please press \"Q\" to download them.]");
goto loop;
}
G->input[u] = G->input[u]-0x30; /* make it a number */
send ("]File added to your list (marked #%d) :",(marked+1));
send (filepick[G->input[u]]);
strcpy(filemark[marked],filepick[G->input[u]]);
downflag[marked]=FALSE; /* show that it's not been downloaded yet */
send (G->CR[u]);
marked++;
goto loop;
}
switch (G->input[u]) {
case 'H':
G->okcancel[u]=TRUE;
G->nocheck[u]=FALSE; /* check for controls */
G->cancel[u]=FALSE;
sendtext (":files:filehelp1.txt");
if (!G->online[u]) goto done;
break;
case 'N':
case '\x0d':
if (lines<10 || (seek <= startfile)){ send("]At last page.]"); goto loop; }
page++;
goto next;
break;
case 'P':
wherewewere=seek;
seek=seek+(CHARSPERFILE*lines);
seek=seek+(CHARSPERFILE*10);
if (seek > (endfile-CHARSPERFILE)){
seek=wherewewere; /* keep it at start */
send("]At First page.]"); goto loop;
}
if (--page < 1) page=1;
goto next;
break;
case 'O':
if (options(folder,line1)){ /* if we have a good name */
removespaces(line1); /* takes out trailing spaces */
strcpy(dirfile,folder);
strcat(dirfile, ":");
strcat(dirfile,line1);
if (filesend(dirfile,line1,&P)) { /* send the file, if bad skip log file*/
if ((P.size=P.size/1000)<1) P.size=1;
size=P.size;
logit(folder,line1,size);
}
}
break;
case 'U':
fileenter(folder); /* allow them to upload */
goto alldone;
break;
case 'Q':
goto done;
break;
case 'M':
marked1=0;
if (marked == 0) {
send ("]You have no files marked]");
break;
}
send ("]Files marked for download :]]");
while (marked1 < marked) {
strcpy(line1,filemark[marked1]);
removespaces(line1); /* takes out trailing spaces */
send ("#%d \"%s\"]",(marked1+1),line1);
marked1++;
}
send (G->CR[u]);
break;
}
goto loop;
done:
marked1=0;
if (marked == 0) {
send ("]You have no files marked, returning to menu..]");
goto alldone;
}
marked--;
next1:
strcpy(line1,filemark[marked1]);
removespaces(line1); /* takes out trailing spaces */
send ("]File ready for download is #%d \"%s\"",(marked1+1),line1);
if (downflag[marked1]) send (" << Successfully downloaded, select next.");
if (!(cmd1("]] Download, Next, Prev, Help, Quit (return = next) :"))) goto byebye;
send(G->CR[u]);
switch (G->input[u]) {
case 'H':
G->okcancel[u]=TRUE;
G->nocheck[u]=FALSE; /* check for controls */
G->cancel[u]=FALSE;
sendtext (":files:filehelp2.txt");
if (!G->online[u]) goto byebye;
break;
case 'N':
case '\x0d':
if (marked1 < marked) marked1++;
else send("]You are at the last file in the list. Use Quit to end.]");
goto next1;
break;
case 'P':
if (marked1 > 0) marked1--;
else send("]You are at the FIRST file in the list.]");
goto next1;
break;
case 'D':
if (downflag[marked1]) {
send ("]]>> You already downloaded this file, are you sure you]");
if (!(cmd1(" want to try again (Y/N) ? "))) goto byebye;
send(G->CR[u]);
if (G->input[u] == 'Y') goto down;
}
else goto down;
break;
case 'Q':
goto alldone;
break;
}
goto next1;
down:
strcpy(dirfile,folder);
strcat(dirfile, ":");
strcat(dirfile,line1);
if (!filesend(dirfile,line1,&P)) { /* send the file, if bad skip log file*/
goto next1;
}
downflag[marked1]=TRUE; /* mark the file as downloaded */
if ((P.size=P.size/1000)<1) P.size=1;
size=P.size;
logit(folder,line1,size);
goto next1;
byebye:
fclose(stream);
G->online[u]=FALSE; /* show we timed out */
return;
alldone:
return;
}
logit(folder,line1,size)
char *folder, *line1;
long size;
{
char datetime[26];
int tries;
FILE *stream;
getdatetime(datetime); /* gets the date & time */
tries = 0;
bsylp:
if ((stream = fopen(":logs:downloadlog", "a")) == NULL) {
if (++tries < MAXFILETRIES) {
send("]PLEASE STANDBY...");
wait(1); /* wait just a bit */
goto bsylp;
}
print("\nFILE ERROR - cannot open downloadlog ");
send("]FILE ERROR - Can't open/create download log file!]");
}
else {
if (fprintf(stream, "%s %s DOWNLOADED \"%s\" %s %ldK\n", datetime, G->username[u], line1, folder, size) < 0) {
send("]FILE ERROR - Download log file file has problem writing]");
}
}
fclose(stream);
}
options(folder,temp)
char *folder;
char *temp;
{
char fname[33];
int bad;
bad=FALSE;
send("] *** Options Menu ***]");
send("]Input the EXACT filename to download (32 characters MAX) :");
portsin(fname, 32);
if (! G->online[u]) return FALSE; /* portsin returns online for a time out */
send(G->CR[u]);
if (strlen(fname) < 1) { send ("]Download canceled.]"); return FALSE; }
if (strchr(fname, '*')) bad = TRUE; /* returns TRUE if it's "*" */
if (strchr(fname, ':')) bad = TRUE; /* returns TRUE if it's ":" */
if (strchr(fname, '\\')) bad = TRUE; /* returns TRUE if it's "\" */
if (strchr(fname, '~')) bad = TRUE; /* returns TRUE if it's "~" */
strcpy(temp,fname);
strtoupper(temp);
if(strcmp(temp,"SYSOP") == 0) bad = TRUE; /* returns TRUE if it's a bad name */
if(strcmp(temp,"SYSTEM") == 0) bad = TRUE;
if(strcmp(temp,"FINDER") == 0) bad = TRUE; /* we DON'T want people to download this stuff !! */
if(strcmp(temp,"DIRECTORY") == 0) bad = TRUE;
if(strcmp(temp,"FILEINTRO.TXT") == 0) bad = TRUE;
if(strcmp(temp,"FILEHELP1.TXT") == 0) bad = TRUE;
if(strcmp(temp,"FILEHELP2.TXT") == 0) bad = TRUE;
if(strcmp(temp,"FILEMENU.TXT") == 0) bad = TRUE;
if(strcmp(temp,"FILEMENU.ANSI") == 0) bad = TRUE;
if (bad) {
send("]Illegal character in filename or illegal filename!]");
return FALSE;
}
return TRUE;
}
filesend(name,justname,P)
char *name, *justname;
struct PPP *P;
{
if (strcmp(G->userbaud[u],"300") == 0) {
send("]Sorry, users logged in at 300 baud are not allowed to upload/download here.]");
return FALSE;
}
strcpy(P->filename,name);
strcpy(P->justname,justname);
P->mode= SEND;
P->result= 9;
module(3,"XFER_Xmodem",P);
if (P->result ==0) {
send("]File transfered OK]");
return TRUE;
}
else {
send("]Some type of error sending file %d]",P->result);
return FALSE;
}
}
filereceive(name,justname,P)
char *name, *justname;
struct PPP *P;
{
strcpy(P->filename,name);
strcpy(P->justname,justname);
P->mode= RECEIVE;
P->result= 9;
module(3,"XFER_Xmodem",P);
if (P->result ==0) {
send("]File transfered OK]");
return TRUE;
}
else {
send("]Some type of error receiving file %d]",P->result);
return FALSE;
}
}